package thread;

public class Demo4 {
    public static void main(String[] args) {
                            //就是要runnable的实例的，看你怎么实例的，用匿名类来实例？或者是普通地实现这个类
        Thread t = new Thread(new Runnable() {//这边环境就是接runnable()的实例
            @Override
            public void run() {
                while (true) {
                    System.out.println("hello thread");
                    try {
                        Thread.sleep(1000);
                    } catch (InterruptedException e) {
                        e.printStackTrace();
                    }
                }
            }
        });
        t.start();

        while (true) {
            System.out.println("hello main");
            try {
                Thread.sleep(1000);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
        }
    }
}
